#include "sscan.h"

namespace eintik::data::scan {

    void SScan::add_frame(const std::vector<int16_t> &frame)
    {
        this->frame.clear();
        for (auto &v : frame) {
            this->frame.push_back(int16_2_uint8(v));
        }
    }

    std::vector<uint8_t> SScan::frame_b_transpose()
    {
        if (frame.empty()) {
            return {};
        }
        auto w = eintik::property::cnt_beam();
        auto h = eintik::property::cnt_points();
        if (w * h != frame.size()) {
            return {};
        }
        std::vector<uint8_t> ret;
        ret.reserve(w * h);
        for (auto i = 0; i < h; i++) {
            for (auto j = 0; j < w; j++) {
                ret.push_back(frame[j * h + i]);
            }
        }
        return ret;
    }
}
